package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.*;
import com.medicine.manage.domain.OrderProcess;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlockOrderProcessServiceImpl extends AbstractBlockMultiplexService<OrderProcess> implements IBlockOrderProcessService {

    private final String INSERT_ONE_METHOD = "insertOrderProcess";
    private final String INSERT_LIST_METHOD = "insertOrderProcesses";
    private final String SELECT_ONE_METHOD = "selectOrderProcessByOrderIdAndId";
    private final String SELECT_LIST_METHOD = "selectOrderProcessByOrderId";
    private final String UPDATE_METHOD = "updateOrderProcessByOrderIdAndId";



    @Override
    public WeBaseResult insertOrderProcessList(List<OrderProcess> orderProcessList, Long deptId, Long optionUserId) {
        return this.insertList(orderProcessList, deptId, optionUserId, INSERT_LIST_METHOD);
    }

    @Override
    public WeBaseResult insertOrderProcess(OrderProcess orderProcess, Long deptId, Long optionUserId) {
        return this.insertOne(orderProcess, deptId, optionUserId, INSERT_ONE_METHOD);
    }

    @Override
    public WeBaseResult selectOrderProcessList(Long orderId, Long deptId, Long optionUserId) {
        return this.selectList(orderId, deptId, optionUserId, SELECT_LIST_METHOD);
    }

    @Override
    public WeBaseResult selectOrderProcess(Long orderId, Long detailId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, detailId, deptId, optionUserId, SELECT_ONE_METHOD);
    }

    @Override
    public WeBaseResult updateOrderProcess(OrderProcess orderProcess, Long deptId, Long optionUserId) {
        return this.update(orderProcess.getOrderId(), orderProcess.getId(), orderProcess,deptId, optionUserId, UPDATE_METHOD);
    }

    @Override
    protected String createParam(OrderProcess o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)
                .append(o.getProcessType()).append(IBlockService.SEPARATOR)
                .append(o.getStatus()).append(IBlockService.SEPARATOR)
                .append(o.getStartTime()==null? "0":o.getStartTime().getTime()).append(IBlockService.SEPARATOR)
                .append(o.getEndTime()==null? "0":o.getEndTime().getTime()).append(IBlockService.SEPARATOR)
                .append(optionUserId);
        System.out.println(param);
        return param.toString();
    }


}
